<template>
    <div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>单位编码</label>
                <i class="iconfont icon-required"></i>
            </div>
            <div>
                <input type="text"
                       placeholder="请输入您的单位编码"
                       v-model="departCode">
            </div>
        </div>
        <div class="btns">
            <button class="width200"
                    @click="GetDepartInfoByCode">提交</button>
        </div>
        <myMenu></myMenu>
    </div>
</template>
<script>
export default {
    name: 'addCompany',
    data () {
        return {
            registerInfo: {},
            departCode: ''
        }
    },
    created () {
        this.registerInfo = JSON.parse(localStorage.getItem('registerInfo'))
    },
    methods: {
        GetDepartInfoByCode () {
            if (!this.departCode) {
                this.$vux.toast.text('请输入单位编码')
                return
            }
            let params = {
                userId: this.registerInfo.userId,
                departCode: this.departCode
            }
            this.$axiosAjax.GetDepartInfoByCode(params).then((res) => {
                if (res.data.code === 0) {
                    this.registerInfo.departName = res.data.data.departName
                    this.registerInfo.departId = res.data.data.departId
                    localStorage.setItem('registerInfo', JSON.stringify(this.registerInfo))
                    this.$router.replace('/epidemicFKEntery')
                } else {
                    this.$vux.toast.text(res.data.info)
                }
            })
        }
    }
}
</script>
<style scoped>
</style>
